<!DOCTYPE html>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html;charset=utf-8">
<title>yukari world</title>
<#include "/lib/base_source.ftl">
<style type="text/css">
</style>
</head>
<body>
<div class='whole-container'>
<#include "/lib/header.ftl">
    <div>
        <ul class="breadcrumb">
        	<li>签到管理</li><span class="divider">/</span>
            <li>签到列表</li>
        </ul>
    </div>
    <div class="container-fluid">
        <div class="row-fluid">
            <div class="container span12">
            <#include "/lib/alert.ftl">

                <div class='main-content'>
                    <div class="well form-inline">
                        <div class='main-action'>
							<form id="banForm">
								禁言人<input name="name" style="width: 200px">&nbsp;&nbsp;&nbsp;&nbsp;
								禁言时间
								<select name="time" style="width: 100px">
									<option value="1">1分钟</option>
									<option value="10">10分钟</option>
									<option value="30">30分钟</option>
									<option value="60">1小时</option>
									<option value="480">8小时</option>
									<option value="1440" selected>1天</option>
									<option value="4320">3天</option>
									<option value="10080">7天</option>
									<option value="43200">30天</option>
								</select>&nbsp;&nbsp;&nbsp;&nbsp;
								禁言理由<input name="message" style="width: 200px">
								<a class="btn btn-sm btn-danger" href="javascript:" onclick="banAuth()">禁言</a>
                            </form>
                        </div>
                    </div>
                    
                    <div class="table-content">
                    <#-- table -->
                        <table class="table table-striped table-bordered table-condensed" id="itemTable" style="font-size:12px;word-break:break-all;word-wrap:break-word;">
                            <thead>
                            <tr >
                                <th>名字</th>
                                <th>开始时间</th>
                                <th>结束时间</th>
                                <th>禁言理由</th>
                                <th>最后弹幕</th>
                                <th>操作人</th>
                                <th>状态</th>
                                <th>操作</th>
                            </tr>
                            </thead>
                            <tbody>
                            <#if list??>
                            <#list list as item>
                            	<tr>
                                	<td>${item.authName}</td>
                                	<td>${item.startTime?string("yyyy-MM-dd HH:mm:ss")}</td>
                                	<td>${item.endTime?string("yyyy-MM-dd HH:mm:ss")}</td>
                                	<td>${item.message}</td>
                                	<td>${item.chatmsg}</td>
                                	<td>${item.executorName}</td>
                                	<td>
										<#if item.autoStatus == 1>
										    自动禁言
										<#elseif item.status == 1>
											禁言
										<#else>
											失效
										</#if>
									</td>
									<td>
										<#if item.autoStatus == 1>
                                            <a class="btn btn-sm btn-danger" href="javascript:updateAutoStatus('${item.id}')" >关闭自动禁言</a>
										<#else>
											<a class="btn btn-sm btn-success" href="javascript:updateAutoStatus('${item.id}')" >开启自动禁言</a>
										</#if>
                                        <#if item.status == 1>
                                            <a class="btn btn-sm btn-success" href="javascript:removeAccount('${item.authId}')">解禁</a>
                                        </#if>
									</td>
                                </tr>
                            </#list>
                            </#if>
                            </tbody>
                        </table>
						<form id="searchForm">
							<input name="size" value="${pager.size}" id="size" type="hidden">
							<input name="page" value="${pager.page}" id="page" type="hidden">
							<input name="total" value="${pager.total}" id="total" type="hidden">
						</form>
                        <div class="pagination" id="itemPage"></div>
                    </div>
                </div>
            </div>
        </div>
    </div>
</div>
<script>

    $(document).ready(function(){
		$.manage.pageList(".pagination","#searchForm","#page","#total","#size");
    });
	    

	function banAuth(){
        $.ajax({
            'url' : "${rc.contextPath}/admin/ban/byAdmin",
            'dataType' : "json",
            'data' :  $("#banForm").serialize(),
            'type':'post',
			'success':function(json){
                if(json.code == 0){
                    location.reload();
				}else{
                    alert(json.message);
				}
			}
		});
	}

	function updateAutoStatus(id){
        $.ajax({
            'url' : "${rc.contextPath}/admin/ban/updateAutoShutUp",
            'dataType' : "json",
            'data' :  {"id":id},
            'type':'post',
            'success':function(json){
                if(json.code == 0){
                    location.reload();
                }else{
                    alert(json.message);
                }
            }
        });
	}
	function removeAccount(id){
        $.ajax({
            'url' : "${rc.contextPath}/admin/ban/removeAccount",
            'dataType' : "json",
            'data' :  {"authId":id},
            'type':'post',
            'success':function(json){
                if(json.code == 0){
                    location.reload();
                }else{
                    alert(json.message);
                }
            }
        });
	}


</script>
</body>
</html>